package com.company.woye.taiorcheckSize.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.company.woye.R;
import com.company.woye.taiorcheckSize.bean.TaiorBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class TaiorListviewAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context mContext;
    private List<TaiorBean.DataBean.ZhiCjypcsTagListBean> listBeans;

    public TaiorListviewAdapter(Context context, List<TaiorBean.DataBean.ZhiCjypcsTagListBean> listBeans) {
        this.inflater = LayoutInflater.from(context);
        this.mContext = context;
        this.listBeans = listBeans;
    }

    @Override
    public int getCount() {
        return listBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return listBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHodler = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.intem_taior_detail, parent, false);
            viewHodler = new ViewHolder(convertView);
            convertView.setTag(viewHodler);
        } else {
            viewHodler = (ViewHolder) convertView.getTag();
        }
        TaiorBean.DataBean.ZhiCjypcsTagListBean dataBean = listBeans.get(position);
        viewHodler.tvCode.setText(dataBean.getTxm());
        viewHodler.tvDBH.setText(dataBean.getDbh());
        viewHodler.tvOrderNo.setText(dataBean.getHyh());
        viewHodler.tvGoodsNo.setText(dataBean.getHh());
        viewHodler.tvPo.setText(dataBean.getPoh());
        viewHodler.tvStyle.setText(dataBean.getCplx());
        viewHodler.tvSh.setText(dataBean.getSh());
        viewHodler.tvSc.setText(dataBean.getSc());
        viewHodler.tvSize.setText(dataBean.getCm());
        viewHodler.tvPart.setText(dataBean.getBw());
        viewHodler.tvBadName.setText(dataBean.getTagName());
        viewHodler.tvBadNum.setText(dataBean.getTagCount());
        return convertView;
    }



    static
    class ViewHolder {
        @BindView(R.id.tv_code)
        TextView tvCode;
        @BindView(R.id.tv_DBH)
        TextView tvDBH;
        @BindView(R.id.tv_orderNo)
        TextView tvOrderNo;
        @BindView(R.id.tv_goodsNo)
        TextView tvGoodsNo;
        @BindView(R.id.tv_po)
        TextView tvPo;
        @BindView(R.id.tv_style)
        TextView tvStyle;
        @BindView(R.id.tv_sh)
        TextView tvSh;
        @BindView(R.id.tv_sc)
        TextView tvSc;
        @BindView(R.id.tv_size)
        TextView tvSize;
        @BindView(R.id.tv_part)
        TextView tvPart;
        @BindView(R.id.tv_bad_name)
        TextView tvBadName;
        @BindView(R.id.tv_bad_num)
        TextView tvBadNum;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
